import 'package:flutter/material.dart';
import 'package:flutterproject/mvvm/base/base_state.dart';
import 'package:flutterproject/page/setting/children/modify_pay_pwd/controller/modify_pay_pwd_controller.dart';
import 'package:flutterproject/util/extension/extension_util.dart';
import 'package:flutterproject/util/extension/widget_extension.dart';
import 'package:flutterproject/util/margin_padding_util.dart';
import 'package:flutterproject/util/sp_util/shared_preferences.dart';
import 'package:flutterproject/util/sp_util/sp_key.dart';
import 'package:flutterproject/widget/app_bar_common.dart';
import 'package:flutterproject/widget/button_common.dart';
import 'package:flutterproject/widget/text/text_common.dart';
import 'package:flutterproject/widget/text/text_field_common.dart';
import 'package:get/get.dart';

class ModifyPayPwdPage extends BaseState<ModifyPayController> {
  @override
  ModifyPayController initController() => ModifyPayController();

  @override
  Widget initView(BuildContext context) {
    return Container(
      color: Color(0xFFF6F6F6),
      child: Column(
        children: [
          AppBarCommon(
            title: "修改支付密码",
          ),
          Container(
            margin: MarginPaddingUtil.all(23),
            padding: MarginPaddingUtil.fromLTRB(
                left: 20, top: 40, right: 20, bottom: 60),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(20.radius),
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                Row(
                  children: [
                    TextCommon(
                      "手机号码",
                      size: 28.sp,
                      fontWeight: FontWeight.bold,
                    ),
                    71.widthBox,
                    TextCommon(
                      "${SPUtils().getLocalStorage(SPKey.mobile)}",
                      size: 28.sp,
                      fontWeight: FontWeight.w500,
                    ),
                  ],
                ),
                52.heightBox,
                Row(
                  children: [
                    TextFieldCommon(
                      controller: controller.codeController,
                      height: 40.width,
                      hintText: "输入手机验证码",
                      size: 28.sp,
                      hintSize: 28.sp,
                    ),
                    Spacer(),
                    GetBuilder<ModifyPayController>(
                        id: "code",
                        builder: (logic) {
                          return TextCommon(
                            controller.isSendCode
                                ? "${controller.countDown}(S)"
                                : "发送验证码",
                            size: 28.sp,
                            color: Color(0xFFEDC88B),
                            fontWeight: FontWeight.w500,
                          ).addClickEvent(() => controller.sendCode());
                        }),
                    50.widthBox,
                  ],
                ),
                25.heightBox,
                Divider(
                  color: Color(0xFFE7E7E7),
                  height: 1.width,
                ),
                25.heightBox,
                TextCommon(
                  "修改支付密码",
                  size: 28.sp,
                  fontWeight: FontWeight.bold,
                ),
                57.heightBox,
                TextFieldCommon(
                  controller: controller.pwdController,
                  height: 40.width,
                  hintText: "输入新的支付密码",
                  size: 28.sp,
                  hintSize: 28.sp,
                ),
                15.heightBox,
                Divider(
                  color: Color(0xFFE7E7E7),
                  height: 1.width,
                ),
              ],
            ),
          ),
          Spacer(),
          Container(
            width: Get.width,
            color: Colors.white,
            padding: MarginPaddingUtil.symmetric(vertical: 22, horizontal: 200),
            child: ButtonCommon(
              text: "确认修改",
              onTap: () => controller.onConfirm(),
              fontSize: 32.sp,
              fontColor: Colors.white,
              color: Color(0xFFEDC88B),
              borderRadios: 50,
              padding: MarginPaddingUtil.only(top: 25, bottom: 29),
            ),
          )
        ],
      ),
    );
  }
}
